package com.classic.okhttp.services;

import com.classic.okhttp.Cons;
import android.app.Activity;
import com.classic.okhttp.base.OkHttpUtils;
import com.classic.okhttp.zmoumall.utils.MD5;
import com.classic.okhttp.zmoumall.http.ACache;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.classic.okhttp.zmoumall.http.ObjectCallback;
import okhttp3.MediaType;
import com.orhanobut.logger.Logger;

import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;

import com.classic.okhttp.beans.HVUserBaseInfoBean;
import com.classic.okhttp.beans.HVUserOtherInfoBean;
import com.classic.okhttp.beans.HVMyOrderInfoBean;
import com.classic.okhttp.beans.HVMyMessageInfoBean;
import com.classic.okhttp.beans.HVVenueBean;
import com.classic.okhttp.beans.HVProductInfoBean;
import com.classic.okhttp.beans.HVCardBean;
import com.classic.okhttp.beans.HVWalkInfoBean;
import com.classic.okhttp.beans.HVWalkCouponBean;


import com.classic.okhttp.enums.Enum;

public class IUserService
{

	private static String _getFullURL(String method)
	{
		return new StringBuffer( Cons.GATEWAY_URL ).append("user/").append(method).toString();
	}

	//获取验证码
	public static void getVerify(Activity activity, String phone, Enum.EnumVerifyType type, boolean isCache, ObjectCallback<Object> callback)
	{
		callback.setCallBackBean(new TypeToken<Object>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("phone", phone);
		params.put("type", type.value);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("getVerify");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(phone).append(type).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//登录
	public static void login(Activity activity, String phone, String pwd, String ipAddress, boolean isCache, ObjectCallback<String> callback)
	{
		callback.setCallBackBean(new TypeToken<String>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("phone", phone);
		params.put("pwd", pwd);
		params.put("ipAddress", ipAddress);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("login");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(phone).append(pwd).append(ipAddress).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//验证码登录
	public static void loginVerify(Activity activity, String phone, String pwd, String ipAddress, boolean isCache, ObjectCallback<String> callback)
	{
		callback.setCallBackBean(new TypeToken<String>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("phone", phone);
		params.put("pwd", pwd);
		params.put("ipAddress", ipAddress);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("loginVerify");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(phone).append(pwd).append(ipAddress).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//登出
	public static void quit(Activity activity, boolean isCache, ObjectCallback<Object> callback)
	{
		callback.setCallBackBean(new TypeToken<Object>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("quit");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//修改密码
	public static void changePassword(Activity activity, String oldPassword, String replacePassword, boolean isCache, ObjectCallback<Object> callback)
	{
		callback.setCallBackBean(new TypeToken<Object>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("oldPassword", oldPassword);
		params.put("replacePassword", replacePassword);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("changePassword");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(oldPassword).append(replacePassword).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//找回密码
	public static void findPassword(Activity activity, String phone, String pwd, String verifyCode, boolean isCache, ObjectCallback<Object> callback)
	{
		callback.setCallBackBean(new TypeToken<Object>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("phone", phone);
		params.put("pwd", pwd);
		params.put("verifyCode", verifyCode);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("findPassword");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(phone).append(pwd).append(verifyCode).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//收藏
	public static void collect(Activity activity, String collectId, Enum.EnumCollect collectType, boolean isCache, ObjectCallback<Object> callback)
	{
		callback.setCallBackBean(new TypeToken<Object>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("collectId", collectId);
		params.put("collectType", collectType.value);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("collect");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(collectId).append(collectType).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//获取用户主要信息
	public static void getUserBaseInfo(Activity activity, boolean isCache, ObjectCallback<HVUserBaseInfoBean> callback)
	{
		callback.setCallBackBean(new TypeToken<HVUserBaseInfoBean>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("getUserBaseInfo");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//获取用户其他信息
	public static void getUserOtherInfo(Activity activity, boolean isCache, ObjectCallback<HVUserOtherInfoBean> callback)
	{
		callback.setCallBackBean(new TypeToken<HVUserOtherInfoBean>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("getUserOtherInfo");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//获取我的订单列表
	public static void getMyOrderInfo(Activity activity, int pageIndex, int pageSize, Enum.EnumOrderState orderState, boolean isCache, ObjectCallback<ArrayList<HVMyOrderInfoBean>> callback)
	{
		callback.setCallBackBean(new TypeToken<ArrayList<HVMyOrderInfoBean>>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("pageIndex", pageIndex);
		params.put("pageSize", pageSize);
		params.put("orderState", orderState.value);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("getMyOrderInfo");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(pageIndex).append(pageSize).append(orderState).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//获取我的消息列表
	public static void getMyMessageList(Activity activity, int pageIndex, int pageSize, boolean isCache, ObjectCallback<ArrayList<HVMyMessageInfoBean>> callback)
	{
		callback.setCallBackBean(new TypeToken<ArrayList<HVMyMessageInfoBean>>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("pageIndex", pageIndex);
		params.put("pageSize", pageSize);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("getMyMessageList");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(pageIndex).append(pageSize).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//获取我的收藏场馆列表
	public static void getMyCollectionVenueList(Activity activity, int pageIndex, int pageSize, int type, Double lng, Double lat, boolean isCache, ObjectCallback<ArrayList<HVVenueBean>> callback)
	{
		callback.setCallBackBean(new TypeToken<ArrayList<HVVenueBean>>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("pageIndex", pageIndex);
		params.put("pageSize", pageSize);
		params.put("type", type);
		params.put("lng", lng);
		params.put("lat", lat);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("getMyCollectionVenueList");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(pageIndex).append(pageSize).append(type).append(lng).append(lat).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//获取我的收藏课程列表
	public static void getMyCollectionProductList(Activity activity, int pageIndex, int pageSize, int type, Double lng, Double lat, boolean isCache, ObjectCallback<ArrayList<HVProductInfoBean>> callback)
	{
		callback.setCallBackBean(new TypeToken<ArrayList<HVProductInfoBean>>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("pageIndex", pageIndex);
		params.put("pageSize", pageSize);
		params.put("type", type);
		params.put("lng", lng);
		params.put("lat", lat);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("getMyCollectionProductList");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(pageIndex).append(pageSize).append(type).append(lng).append(lat).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//取消收藏
	public static void cancelMyCollection(Activity activity, Enum.EnumCollect collectType, String collectId, boolean isCache, ObjectCallback<Object> callback)
	{
		callback.setCallBackBean(new TypeToken<Object>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("collectType", collectType.value);
		params.put("collectId", collectId);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("cancelMyCollection");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(collectType).append(collectId).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//修改用户信息
	public static void modifyUser(Activity activity, Enum.EnumUserFieldType fieldType, String fieldValue, boolean isCache, ObjectCallback<Object> callback)
	{
		callback.setCallBackBean(new TypeToken<Object>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("fieldType", fieldType.value);
		params.put("fieldValue", fieldValue);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("modifyUser");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(fieldType).append(fieldValue).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//查询用户优惠券列表
	public static void getCardList(Activity activity, String venueId, boolean isCache, ObjectCallback<ArrayList<HVCardBean>> callback)
	{
		callback.setCallBackBean(new TypeToken<ArrayList<HVCardBean>>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("venueId", venueId);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("getCardList");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(venueId).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//获取优惠券详情
	public static void getCardInfo(Activity activity, String couponId, Integer couponUserId, boolean isCache, ObjectCallback<HVCardBean> callback)
	{
		callback.setCallBackBean(new TypeToken<HVCardBean>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("couponId", couponId);
		params.put("couponUserId", couponUserId);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("getCardInfo");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(couponId).append(couponUserId).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//用户领取优惠券
	public static void addUserCard(Activity activity, String code, boolean isCache, ObjectCallback<Boolean> callback)
	{
		callback.setCallBackBean(new TypeToken<Boolean>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("code", code);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("addUserCard");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(code).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//注册通知推送
	public static void registerNotification(Activity activity, String clientId, boolean isDebug, boolean isCache, ObjectCallback<Object> callback)
	{
		callback.setCallBackBean(new TypeToken<Object>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("clientId", clientId);
		params.put("isDebug", isDebug);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("registerNotification");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(clientId).append(isDebug).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//添加意见反馈和举报
	public static void addFeedBack(Activity activity, String content, String venueId, Enum.EnumFeedBackType type, boolean isCache, ObjectCallback<Boolean> callback)
	{
		callback.setCallBackBean(new TypeToken<Boolean>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("content", content);
		params.put("venueId", venueId);
		params.put("type", type.value);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("addFeedBack");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(content).append(venueId).append(type).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//获取用户步数
	public static void getWalkInfo(Activity activity, long walkDate, boolean isCache, ObjectCallback<HVWalkInfoBean> callback)
	{
		callback.setCallBackBean(new TypeToken<HVWalkInfoBean>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("walkDate", walkDate);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("getWalkInfo");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(walkDate).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//获取步行优惠券列表
	public static void getWalkCouponList(Activity activity, boolean isCache, ObjectCallback<ArrayList<HVWalkCouponBean>> callback)
	{
		callback.setCallBackBean(new TypeToken<ArrayList<HVWalkCouponBean>>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("getWalkCouponList");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//报告步数
	public static void reportWalk(Activity activity, long walkDate, int stepNumber, boolean isCache, ObjectCallback<Object> callback)
	{
		callback.setCallBackBean(new TypeToken<Object>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("walkDate", walkDate);
		params.put("stepNumber", stepNumber);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("reportWalk");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(walkDate).append(stepNumber).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//兑换步行优惠券
	public static void addWalkCoupon(Activity activity, Integer couponId, boolean isCache, ObjectCallback<Object> callback)
	{
		callback.setCallBackBean(new TypeToken<Object>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("couponId", couponId);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("addWalkCoupon");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(couponId).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//领取首单优惠券
	public static void addFirstOrderCoupon(Activity activity, String venueId, boolean isCache, ObjectCallback<Integer> callback)
	{
		callback.setCallBackBean(new TypeToken<Integer>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("venueId", venueId);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("addFirstOrderCoupon");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(venueId).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//抽奖
	public static void luckDraw(Activity activity, String fromUserId, boolean isCache, ObjectCallback<String> callback)
	{
		callback.setCallBackBean(new TypeToken<String>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("fromUserId", fromUserId);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("luckDraw");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(fromUserId).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//助力
	public static void cutPrice(Activity activity, String objectUserId, String nickName, String headImgUrl, boolean isCache, ObjectCallback<String> callback)
	{
		callback.setCallBackBean(new TypeToken<String>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("objectUserId", objectUserId);
		params.put("nickName", nickName);
		params.put("headImgUrl", headImgUrl);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("cutPrice");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(objectUserId).append(nickName).append(headImgUrl).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//获取助力记录
	public static void getCutPriceList(Activity activity, String userId, boolean isCache, ObjectCallback<String> callback)
	{
		callback.setCallBackBean(new TypeToken<String>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();
		params.put("userId", userId);

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("getCutPriceList");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).append(userId).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}

	//领取助力优惠券
	public static void addCutPriceCoupon(Activity activity, boolean isCache, ObjectCallback<String> callback)
	{
		callback.setCallBackBean(new TypeToken<String>(){}.getType());
		callback.setContext(activity);

		Map<String, Object> params = new HashMap<>();

		Gson gson=new Gson();
		String json=gson.toJson(params);

		String url = _getFullURL("addCutPriceCoupon");

		if(isCache) {//添加缓存
			String key = MD5.MD5Encode(new StringBuffer(url).toString());
			ACache aCache = ACache.get(activity);
			callback.setACache(aCache, key, isCache);
		}

		OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json;charset=utf-8"))
               	.url(url)
                .content(json)
                .addHeader("Token",Cons.mToken)
                .addHeader("DeviceID",Cons.mDeviceId)
				.addHeader("DeviceType",Cons.mDeviceType)
				.addHeader("Version",Cons.mVersion)
				.addHeader("VersionCode",Cons.mVersionCode)
				.addHeader("Data",Cons.getData(json))
				.addHeader("AppType",Cons.getAppType())
                .tag(activity)
                .build()
                .execute(callback);
	}
}
